package cn.itsource.hrm.feign.fallback;

import cn.itsource.hrm.feign.client.CourseDocClient;
import cn.itsource.hrm.to.CourseDocTO;
import cn.itsource.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CourseDocFallbackFactory implements FallbackFactory<CourseDocClient> {

    @Override
    public CourseDocClient create(Throwable throwable) {

        return new CourseDocClient() {
            @Override
            public AjaxResult onLineCourse(CourseDocTO courseTO) {
                log.info(throwable.getMessage());
                return AjaxResult.me().setSuccess(false).setMessage("课程发布失败，我们正在殴打程序员！！");
            }
        };
    }
}
